package org.advanced.pool;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author John.zhang
 * @version Id: ThreadPools, v 1.0 2020/12/11 15:27 ZhiYong Exp $
 */
public class ThreadPools implements Runnable{

    public static void main(String[] args) {
        ThreadPoolExecutor executorService = (ThreadPoolExecutor)ExecutorSelf.newFixedThreadPool(3);
        executorService.prestartAllCoreThreads();//提前预热所有核心线程
        int max = 10;
        for (int i=0;i<max;i++){
            executorService.execute(new ThreadPools());
        }
        executorService.shutdown();
    }

    @Override
    public void run() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
